package CustomUI;

import DTO.DrawingActionDTO;
import DTO.DrawingPlaneDTO;
import GameTools.ydPoint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Region;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

public class SaveView extends View {
	
	int blackTint=Color.argb(128, 0, 0, 0);
	
	ydPoint p1=new ydPoint();
	ydPoint p2=new ydPoint();

	public SaveView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	public SaveView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
	}

	public SaveView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		 canvas.clipRect(p1.x, p1.y, p2.x, p2.y, Region.Op.DIFFERENCE);
		canvas.drawARGB(128, 0, 0, 0);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		float x = event.getX();
        float y = event.getY();
		if(event.getAction() == MotionEvent.ACTION_DOWN){
			p1.setCoordinates(x,y);
			p2.setCoordinates(x,y);
        }else if(event.getAction() == MotionEvent.ACTION_MOVE){
        	p2.setCoordinates(x,y);
        }else if(event.getAction() == MotionEvent.ACTION_UP){
        	p2.setCoordinates(x,y);
        }
		invalidate();
		return true;
	}

}
